package com.jt.assistant.ui

import android.graphics.Color
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.ViewModel
import com.jt.assistant.R
import com.jt.assistant.bean.UpdateAppBean
import com.jt.assistant.viewmodel.HomeViewModel
import com.open.hule.library.entity.AppUpdate
import com.open.hule.library.utils.UpdateManager
import com.orhanobut.logger.Logger
import com.yzp.mvvmlibrary.base.BaseActivity
import kotlinx.android.synthetic.main.activity_download.*

class DownloadActivity : BaseActivity<HomeViewModel>() {
    override fun layoutId(): Int = R.layout.activity_download

    override fun initView(savedInstanceState: Bundle?) {
    }

    override fun initData() {
    }

    override fun initListener() {
        button.setOnClickListener {
            update("https://lsmhw.oss-cn-shenzhen.aliyuncs.com/lsmhw/lumafenfa/apk/2021/04/07/1855_2021_04_07_10_46_024491.apk")//https://lsmhw.oss-cn-shenzhen.aliyuncs.com/lsmhw/lumafenfa/apk/2021/04/07/1855_2021_04_07_10_46_024491.apk
        }
    }


    private fun update(data: String) {
        //http://40.73.59.226:1889/api/apk/d8e14db8fa0d4724a64217e0098bc29e.apk
        // 更新的数据参数
        val appUpdate = AppUpdate.Builder()
            .newVersionUrl(data)
            .newVersionCode("")
            .updateResourceId(R.layout.dialog_update)
            .updateTitle(R.string.update_title)
            .updateContentTitle(R.string.update_content_lb)
            .updateInfo("")
            .downBrowserUrl(data)
            .isSilentMode(false)
            .updateProgressColor(Color.BLACK)
            .build()
        UpdateManager().startUpdate(this, appUpdate)
    }
}

